// Copyright (c) 2009 Cloudage

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

#pragma once

#include <boost/smart_ptr.hpp>

namespace LuabindSensor
{	
	using namespace boost;
	using namespace std;
	enum InfoType
	{
		IT_Object,
		IT_Class,
		IT_Function,
		IT_Property,
		IT_Table,
		IT_Others
	};

	struct Info
	{
		typedef shared_ptr<Info> SharePtr;
		typedef weak_ptr<Info> WeakPtr;

		virtual InfoType GetInfoType() const {return IT_Others;}
        luabind::object obj;
		std::string name;		
		int address;		
	};

	struct PropertyInfo:public Info
	{	
		typedef shared_ptr<PropertyInfo> SharePtr;		
		typedef vector<SharePtr> List;

		virtual InfoType GetInfoType() const {return IT_Property;}
		bool isReadOnly;
		string typeName;
	};

	struct FunctionInfo:public Info
	{	
		typedef shared_ptr<FunctionInfo> SharePtr;
		typedef vector<SharePtr> List;

		virtual InfoType GetInfoType() const {return IT_Function;}
		
		string signature;				
	};

	struct ClassInfo:public Info
	{	
		typedef pair<std::string,int> EnumItem;
		typedef vector<EnumItem> EnumList;
		typedef shared_ptr<ClassInfo> SharePtr;
		typedef weak_ptr<ClassInfo> WeakPtr;
		typedef vector<SharePtr> List;

		virtual InfoType GetInfoType() const {return IT_Class;}
		std::string cppName;
		FunctionInfo::List methods;
		FunctionInfo::List staticMethods;
		PropertyInfo::List properties;
		EnumList enums;
		bool isCppClass;
	};

	struct ObjectInfo:public Info
	{	
		typedef shared_ptr<ObjectInfo> SharePtr;
		typedef weak_ptr<ObjectInfo> WeakPtr;
		typedef vector<SharePtr> List;

		virtual InfoType GetInfoType() const {return IT_Object;}
		ClassInfo::WeakPtr type;
		std::string luaType;
		std::string value;
	};


	struct TableInfo:public Info
	{	
		typedef shared_ptr<TableInfo> SharePtr;
		typedef weak_ptr<TableInfo> WeakPtr;
		typedef vector<SharePtr> List;
		typedef vector<WeakPtr> WeakList;
		virtual InfoType GetInfoType() const {return IT_Table;}
		TableInfo::List subTables;
		TableInfo::WeakList referenceTables;
		ClassInfo::List classes;
		FunctionInfo::List functions;
		ObjectInfo::List others;
	};
}
